<template>
    <div>



      <el-select  style="margin-left: 5px;
    width: 252px;" @change="changeParkfieldName" v-model="queryParams.searchParkfieldName" filterable placeholder="请选择泊位名称">
   
          <el-option
            v-for="item in parkfieldList"
            :key="item.lockMac"
            :label="item.lockAddress"
            :value="item.lockMac">
          </el-option>
        </el-select>
  

      <el-row class="lock-btn" style='margin-top:10px'>
        
        <el-input @keyup.enter.native="queryBtn" v-model="queryParams.userId" @input="emptyVal" style="width:250px;float: left;margin-left:5px;" clearable placeholder="请输入mac"></el-input>
        <!-- <el-input v-model="queryParams.searchParkfieldName" @input="emptyParkfieldName" style="width:250px;float: left;margin-left:5px;" clearable placeholder="请输入停车场名称"></el-input> -->
 
        <el-button-group style="margin-left:5px;">
          <el-button size="medium" type="primary" @click="queryBtn" round>搜索</el-button>
        </el-button-group>

        <span style="margin-left: 95px;color: #f6f6f6;background: #3f97e9;padding: 10px;">{{managerName}}</span>
        
      </el-row>

    
      <el-row>
            <el-col :xs="12" :sm="12" :md="12" :lg="10" :xl="8" style="text-align: left;margin-bottom: 0px;margin-top: 20px;margin-left: 20px;">
                <span style="margin-bottom: 20px;">泊位名称：</span>
                <el-input disabled style="margin-top:10px;color:#000000"  v-model="parkfieldName"></el-input>
          </el-col>

          <el-button-group style="margin-left: 37px;margin-top: 45px;">
          <el-button size="medium" type="warning" @click="queryBtn2" round>设备上报</el-button>
        </el-button-group>
          </el-row>

  
        <el-row>
        <el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="8">
          <el-form ref="" v-if="showtag" style="box-shadow: rgb(205 205 205) 1px 1px 8px;background:#ffffff;padding: 30px 0px 30px 0px;border-radius: 10px;margin-top:20px;margin-left: 10px;padding:20px;width:402px">
           

            <el-row style="margin-top: 10px;" v-if="showPark">
            <el-col span="10" style="text-align: left;">
                <el-button style="width:400px;height:80px;font-size: 18px;" type="primary"  @click="SearchState1">状态查询</el-button>
          </el-col>
          </el-row>

          <el-row style="margin-top: 10px;" v-if= "showOther">
            <el-col span="12" style="text-align: left;">
                <el-button style="width:195px;height:80px;font-size: 18px;" type="success"  @click="SearchState2">充电电量</el-button>
          </el-col>
          <el-col span="12" style="text-align: left;">
                <el-button style="width:195px;height:80px;font-size: 18px;" type="danger"  @click="SearchState3">充电桩状态</el-button>
          </el-col>
          </el-row>

          <el-row style="margin-top: 10px;" v-if="showOther">
            <el-col span="10" style="text-align: left;">
                <el-button style="width:400px;height:80px;font-size: 18px;" type="primary"  @click="SearchState4">现场实况</el-button>
          </el-col>
          </el-row>



          <el-row style="margin-top: 10px;" v-if="showPark">
            <el-col span="12" style="text-align: left;">
                <el-button style="width:195px;height:80px;font-size: 18px;" type="success"  @click="SearchState9">故障复位</el-button>
          </el-col>
          <el-col span="12" style="text-align: left;">
                <el-button style="width:195px;height:80px;font-size: 18px;" type="danger"  @click="SearchState5">泊控器状态</el-button>
          </el-col>
          </el-row>
   

          <el-row style="margin-top: 10px;" v-if="showOther">
            <el-col span="12" style="text-align: left;">
                <el-button style="width:195px;height:80px;font-size: 18px;" type="warning" @click="SearchState6">实时采集图像</el-button>
          </el-col>
            <el-col span="12" style="text-align: left;font-size: 50px;">
                <el-checkbox v-model="checkedLight" @change="checkval" style="font-size: 50px;margin-left: 50px;" label="是否曝光"></el-checkbox>
          </el-col>
          
          </el-row>

          <el-row style="margin-top: 10px;" v-if="showPark">
            <el-col span="12" style="text-align: left;">
                <el-button style="width:195px;height:80px;font-size: 18px;" type="success" @click="SearchState7">雷达</el-button>
          </el-col>
          <el-col span="12" style="text-align: left;">
                <el-button style="width:195px;height:80px;font-size: 18px;" type="danger" @click="SearchState8">测距</el-button>
          </el-col>
          </el-row>
          
          </el-form>
        </el-col>
        <el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="6">
          <el-form ref="" v-loading="loading" v-if="showtag" style="box-shadow: rgb(205 205 205) 1px 1px 8px;height: 535px; background:#ffffff;padding: 30px 0px 30px 0px;border-radius: 10px;margin-top:20px;margin-left: 10px;padding:20px;width:402px;margin-left:10px;text-align: center;">
                <el-form v-if="flagShow1" style="margin-top:30px;font-size: 18px;">
                <span>状态值：<span class="flag">{{flag.flag0}}</span></span><br/><br/>
                <span>气囊：<span class="flag">{{flag.flag1}}</span></span><br/><br/>
                <span>落杆遇气囊：<span class="flag">{{flag.flag2}}</span></span><br/><br/>
                <span>落杆遇雷达：<span class="flag">{{flag.flag4}}</span></span><br/><br/>
                <span>结算失败：<span class="flag">{{flag.flag8}}</span></span><br/><br/>
                <span>充电时雷达无信号：<span class="flag">{{flag.flag16}}</span></span><br/><br/>
                <span>限位开关异常：<span class="flag">{{flag.flag32}}</span></span><br/><br/>
                <span>落杆7s超时：<span class="flag">{{flag.flag64}}</span></span><br/><br/>
                <span>插枪：<span class="flag">{{flag.flag128}}</span></span><br/><br/>             
                </el-form>

                <el-form v-if="flagShow2" style="margin-top:150px;font-size: 18px;">
                <span>历史电量:<span class="flag">{{chargeCalc.elecTotalAll}}</span></span><br/><br/>
                <span>充电桩末次充电:<span class="flag">{{chargeCalc.elecTotalLast}}</span></span><br/><br/>
                <span>电流:<span class="flag">{{chargeCalc.elecCurrentNum}}</span></span><br/><br/>
                <span>电压:<span class="flag">{{chargeCalc.voltageNum}}</span></span><br/><br/>        
                </el-form>

                <el-form v-if="flagShow3" style="margin-top:180px;font-size: 18px;">
                <span><span class="flag">{{chargeStatusText}}</span></span><br/><br/>
                </el-form>

                <el-form v-if="flagShow4" style="margin-top:30px;font-size: 18px;">
               <el-image :src="src"></el-image>
                </el-form>

                <el-form v-if="flagShow5" style="margin-top:180px;font-size: 18px;">
                    <span class="flag">{{lockStatusText}}</span>
                </el-form>

                <el-form v-if="flagShow6" style="margin-top:30px;font-size: 18px;">
                    <el-image :src="getLiveImageText"></el-image>
                </el-form>

                <el-form v-if="flagShow7" style="margin-top:180px;font-size: 18px;">
                <span><span class="flag">{{radarText}}</span></span><br/><br/>
                </el-form>

                <el-form v-if="flagShow8" style="margin-top:30px;font-size: 18px;">
                <span>雷达距离:<br><br><span class="flag">{{queryRadarDistText}}</span></span><br><br>
                <span>横杆高度:<br><br><span class="flag">{{queryRadarDistText2}}</span></span>
                </el-form>

                <el-form v-if="flagShow9" style="margin-top:30px;font-size: 18px;">
                <span><span class="flag">{{clear}}</span></span>
                </el-form>
                
                

          </el-form>    
        </el-col>
       </el-row>   
           


     <el-dialog
      title="设备处理"
      :visible.sync="addDialog3"
      :width="'800px'"
      :destroy-on-close="true"
    >
      <el-form :rules="rules" :model="feeForm" ref="feeForm">


        <el-row>
          <el-col span="11">
            <el-form-item label="工单号" :label-width="labelWidth" prop="faultNo">
              <el-input
                v-model="feeForm.faultNo"
                disabled
                auto-complete="off"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col span="11">
            <el-form-item label="mac" :label-width="labelWidth" prop="lockMac">
              <el-input
                v-model="feeForm.lockMac"
                disabled
                auto-complete="off"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col span="12">
            <el-form-item
              label="站点名称"
              :label-width="labelWidth"
              prop="lockName"
            >
              <el-input
                v-model="feeForm.lockName"
                disabled
                auto-complete="off"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col span="18">
            <el-form-item
              label="问题描述"
              :label-width="labelWidth"
              prop="faultDesc"
            >

            <el-select v-model="feeForm.faultDesc" placeholder="请选择问题类型" >
                <el-option key="0" label="设备离线" :value="0"></el-option>
                <el-option key="1" label="设备掉电" :value="1"></el-option>
                <el-option key="2" label="起落异常" :value="2"></el-option>
                <el-option key="3" label="充电异常" :value="3"></el-option>
                <el-option key="4" label="部件损坏" :value="4"></el-option>
                <!-- <el-option key="5" label="其他" :value="5"></el-option> -->
              </el-select>
            <!-- <el-input
                type="textarea"
                :rows="2"
              
                placeholder="请输入内容"
                v-model="feeForm.faultDesc">
              </el-input> -->
              
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col span="18">
            <el-form-item
              label="拟解决方案"
              :label-width="labelWidth"
              prop="procMethod"
            >
 
            <el-select v-model="feeForm.procMethod" placeholder="请选择解决方案" >
                <el-option key="0" label="现场排查" :value="0"></el-option>
                <el-option key="1" label="断电重启" :value="1"></el-option>
                <el-option key="2" label="检查通讯模块" :value="2"></el-option>
                <el-option key="3" label="更换电路板" :value="3"></el-option>
                <el-option key="4" label="更换枪线" :value="4"></el-option>
                <el-option key="5" label="钣金修复" :value="5"></el-option>
                <el-option key="6" label="更换雷达" :value="6"></el-option>
                <el-option key="7" label="更换挡杆部件" :value="7"></el-option>
                <el-option key="8" label="更换电路控制板" :value="8"></el-option>
                <el-option key="9" label="更换开关电源" :value="10"></el-option>
                <el-option key="10" label="更换电机控制器" :value="10"></el-option>
                <el-option key="11" label="更换空开" :value="11"></el-option>
                <el-option key="12" label="更换急停" :value="12"></el-option>
                <el-option key="13" label="更换电表" :value="13"></el-option>
                <el-option key="14" label="自动恢复" :value="14"></el-option>
                <el-option key="15" label="人工处理" :value="15"></el-option>
                <el-option key="16" label="其他" :value="16"></el-option>
              </el-select>

              <!-- <el-input
              type="textarea"
                :autosize="{ minRows: 3, maxRows: 5}"
                placeholder="请输入内容"
                v-model="feeForm.procMethod"
                auto-complete="off"
              ></el-input> -->
            </el-form-item>
          </el-col>


        </el-row>


        <el-row>
          <!-- <el-col span="12">
            <el-form-item label="是否上报" :label-width="labelWidth" prop="isReport">
       <el-checkbox
        style="margin-left: 30px"
        v-model="checked"
        @change="checkValue"
        >上报</el-checkbox>
            </el-form-item>
          </el-col> -->
          <el-col span="12">
            <el-form-item label="问题来源" :label-width="labelWidth" prop="faultSource">
              <el-select v-model="feeForm.faultSource" placeholder="请选择">
                <el-option key="0" label="主动上报" :value="0"></el-option>
                <el-option key="1" label="人工巡检" :value="1"></el-option>
                <el-option key="2" label="用户反馈" :value="2"></el-option>
                <el-option key="3" label="其他" :value="3"></el-option>
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>
        <!-- <el-row>
        <el-col span="12" v-if="feeForm.procRate == 2">
          <el-form-item
              label="推送人员"
              :label-width="labelWidth"
              prop="opPerson"
            >
            <el-select  style="margin-left: 5px;
              width: 252px;"  v-model="feeForm.opPerson" filterable placeholder="请选择推送人员">
   
            <el-option
            v-for="item in opPersonList"
            :key="item[0]"
            :label="item[1]"
            :value="item[0]+','+item[1]">
          </el-option>
        </el-select>
            </el-form-item>
          </el-col>
     
    
        </el-row> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancle3">取消</el-button>
        <el-button type="primary" @click="Channelcheck3">处理</el-button>
      </div>
    </el-dialog>
  
  </div>
  </template>
  
  <script>
   
  import { getNickName, getTestUserName,getRoleCode} from "../../util/auth";
  import {searchState1Api,loadMacApi,chargeCalcApi,chargeStatusApi,getPicApi,lockStatusApi,getLiveImageApi,radarApi,queryRadarDistApi,lcfaultprocApi,softResetApi,loadOpPersonListApi} from '../../api/lockManager';
  import {
  loadLocksApi
} from "../../api/parkLock.js";
import Axios from 'axios';

  export default {
    name: "lcredepositrequest",
    data: function () {
      return {
        clientHeight:
          Math.max(
            document.documentElement.scrollHeight,
            document.body.scrollHeight
          ) -
          132 -
          5 +
          10 -
          28,
        labelWidth: "130px",
        loading: false,
        showtag:true,
        lockMac:'',
        checked:false,
        checkedLight:false,
        labelWidth: "100px",
        roleCode:'',
        managerName:'',
        clear:'',
        opPersonList:[],
        parkfieldList:[],
        src:'',
        feeForm:{
          faultNo:'',
          lockMac:'',
          lockName:'',
          faultDesc:'',
          procMethod:'',
          faultSource:'',
          isReport:'',
          opPerson:'',
          procRate:''
        },
        rules: {
          faultDesc: [
            { required: true, message: '请输入问题描述', trigger: 'blur' }
          ],
          faultSource: [
            { required: true, message: '请输入问题来源', trigger: 'change' }
          ]
      },
        ceshi:'',
        faultNo:"",
        isReport:false,
        lockMac:"",
        lockName:"",
        faultDesc:"",
        procMethod:"",
        faultSource:0,
        opPerson:"",
        addDialog3:false,
        lockStatusText:'',
        flagShow1:false,
        showPark:true,
        showOther:true,
        flagShow2:false,
        flagShow3:false,
        flagShow4:false,
        flagShow5:false,
        flagShow6:false,
        flagShow7:false,
        flagShow8:false,
        getLiveImageText:'',
        chargeStatusText:'',
        queryRadarDistText:'',
        queryRadarDistText2:'',
        radarText:'',
        parkfieldName:'',
        onLight:0,
        lockType:'',
        mac:'',
        flag:{flag0:'',flag1:'',flag2:'',flag4:'',flag8:'',flag16:'',flag32:'',flag64:'',flag128:''},
        chargeCalc:{elecTotalAll:'',elecTotalLast:'',elecCurrentNum:'',voltageNum:''},
        queryParams:{userId:'',searchParkfieldName:''},
        // 51300060102
      };
    },
    methods: {

      loadPerson () {
        let _this = this;

        loadOpPersonListApi({roleCode:_this.roleCode,mac:_this.queryParams.userId}).then(function (resp) {
          if (resp.errmsg === "ok") {

            const resdata = resp.data
       
            for(var i in resdata){
         
                resdata[i] = resdata[i].split(";")
            }
       console.log("999",resdata)
            _this.opPersonList = resdata;
        }
        })
        .catch(function (e) {
  
        });
     },
  

    loadParkfields (pageNo, pageSize) {
        let _this = this;

        loadLocksApi({pageNo:pageNo, pageSize:pageSize,name:_this.queryParams.lockMac}).then(function (resp) {
          if (resp.errmsg === "ok") {
            _this.parkfieldList = resp.data.dataList;
        }
        })
        .catch(function (e) {
  
        });
        },

        changeParkfieldName:function(e){

          console.log("99999999999999999999",e)
        let _this = this;
        _this.queryParams.userId = _this.queryParams.searchParkfieldName
        _this.parkfieldName = ''
        this.queryBtn();

// _this.lockMac = 
        },

        emptyVal(){
            var _this = this
            _this.lockMac = ''
            _this.parkfieldName = ''
        },
        checkValue(e){
          var _this = this
          if(e == true){
            _this.feeForm.isReport = true
          }else if(e == false){
            _this.feeForm.isReport = false
          }
        },
      SearchState1(){


         var _this = this;
         if(_this.lockMac != null && _this.lockMac != undefined && _this.lockMac != ''){
            _this.flagShow2 = false;_this.flagShow3 = false;_this.flagShow4 = false;_this.flagShow5 = false;_this.flagShow6 = false;_this.flagShow7 = false;_this.flagShow8 = false;
            _this.flagShow9 = false; 
            _this.flagShow1 = true;
            _this.loading = true;
          searchState1Api(_this.lockMac,_this.roleCode).then(resp => {  
            if(resp.errmsg == 'ok'){ 
            _this.flag.flag0 = resp.data.data;
            _this.flag.flag1 = (parseInt(resp.data.data,16) & 1) > 0?1:0; //气囊
            _this.flag.flag2 = (parseInt(resp.data.data,16) & 2) > 0?1:0; //落杆遇气囊
            _this.flag.flag4 = (parseInt(resp.data.data,16) & 4) > 0?1:0; //落杆遇雷达
            _this.flag.flag8 = (parseInt(resp.data.data,16) & 8) > 0?1:0; //结算失败
            _this.flag.flag16 = (parseInt(resp.data.data,16) & 16) > 0?1:0; //充电时雷达无信号
            _this.flag.flag32 = (parseInt(resp.data.data,16) & 32) > 0?1:0; //限位开关异常
            _this.flag.flag64 = (parseInt(resp.data.data,16) & 64) > 0?1:0; //落杆7s遇阻
            _this.flag.flag128 = (parseInt(resp.data.data,16) & 128) > 0?1:0; //插枪
            _this.loading = false;
            }
        })
        .catch(resp => {
          if(resp.errmsg.indexOf("not.online") != -1){
            alert('此泊控器已离线!')
          }else if(resp.errmsg.indexOf("not.owner") != -1){
            alert('您没有操作权限!')
          }else if(resp.errmsg.indexOf("not.exist") != -1){
            alert('此泊控器不存在!')
          }else{}
          _this.loading = false;
        })
      }else{
        alert("请输入mac")
      }
      },

      SearchState2(){
         var _this = this;
         if(_this.lockMac != null && _this.lockMac != undefined && _this.lockMac != ''){
            _this.flagShow1 = false;_this.flagShow3 = false;_this.flagShow4 = false;_this.flagShow5 = false;_this.flagShow6 = false;_this.flagShow7 = false;_this.flagShow8 = false;
            _this.flagShow9 = false; 
            _this.flagShow2 = true;
            _this.loading = true;
            chargeCalcApi(_this.lockMac,_this.roleCode).then(resp => {   
                var elecCurrentNum = resp.data.batteryRespMessage.elecCurrentNum;
                var voltageNum = resp.data.batteryRespMessage.voltageNum;       
                var elecTotal = resp.data.batteryRespMessage.endElectricityNum;

                if(resp.data.batteryRespMessage.startElectricityNum > 0){
                    elecCurrentNum = elecCurrentNum / 10.0;
                    voltageNum = voltageNum / 10.0;
                  }
                    var urls = [0.001,0.002,0.003,0.004,0,-0.001,-0.002,-0.003,-0.004];
                    var element = urls[Math.floor((Math.random()*urls.length))];
                    var elecTotalAll;
                    if(elecTotal == null || Number(elecTotal)<=0){
                    elecTotalAll = 0.000
                    }else{
                    elecTotalAll = Number(elecTotal) + element;
                    elecTotalAll= elecTotalAll.toFixed(3);
                    } 
                    var urls2 = [0.001,0.002,0.003,0.004,0,-0.001,-0.002,-0.003,-0.004];
                    var element2 = urls2[Math.floor((Math.random()*urls.length))];
                    var elecTotalLast = Math.abs(resp.data.batteryRespMessage.electricityNum-resp.data.batteryRespMessage.startElectricityNum)+ element2;
                    if(Number(elecTotalLast) <= 0.004 || elecTotalLast == null){
                    elecTotalLast = 0.000
                    }else{
                    elecTotalLast= elecTotalLast.toFixed(3);
                    }
                    _this.chargeCalc.elecTotalAll = elecTotalAll +"(度)";
                    _this.chargeCalc.elecTotalLast = elecTotalLast +"(度)";
                    _this.chargeCalc.elecCurrentNum = elecCurrentNum.toFixed(2) +"A";
                    _this.chargeCalc.voltageNum = voltageNum.toFixed(2) +"V";
                    _this.loading = false;
            })
            .catch(resp => {
                if(resp.errmsg.indexOf("not.online") != -1){
                    alert('此充电桩已离线!')
                }else if(resp.errmsg.indexOf("not.owner") != -1){
                    alert('您没有操作权限!')
                }else if(resp.errmsg.indexOf("not.exist") != -1){
                    alert('此充电桩不存在!')
                }else{}
                _this.loading = false;
                })
      }else{
        alert("请输入mac")
      }
      },

      SearchState3(){
         var _this = this;
         if(_this.lockMac != null && _this.lockMac != undefined && _this.lockMac != ''){
            _this.flagShow2 = false;_this.flagShow1 = false;_this.flagShow4 = false;_this.flagShow5 = false;_this.flagShow6 = false;_this.flagShow7 = false;_this.flagShow8 = false;
            _this.flagShow9 = false; 
            _this.flagShow3 = true;
            _this.loading = true;
            chargeStatusApi(_this.lockMac,_this.roleCode).then(resp => {  
            if(resp.errmsg == 'ok'){ 
                var datasplit= resp.data.data.split(';')
                var isCharging = ",订单结束," + datasplit[1] ;
                if(resp.data != null && datasplit[0] == "0"){
                   isCharging=",订单进行中," + datasplit[1]} 

                if(resp.data.batteryRespMessage.workStatus == 0 &&
                  resp.data.batteryRespMessage.chargeStatus == 1 &&
                  resp.data.batteryRespMessage.plugStatus == 1){
                  _this.chargeStatusText = '充电桩未插枪-空闲正常' + isCharging
          }else if(resp.data.batteryRespMessage.workStatus == 0  && 
                 resp.data.batteryRespMessage.chargeStatus == 1 && 
                 resp.data.batteryRespMessage.plugStatus == 2){
                  _this.chargeStatusText = '充电桩插枪-空闲正常' + isCharging
          } else if(resp.data.batteryRespMessage.workStatus == 0  &&
                    resp.data.batteryRespMessage.chargeStatus == 2 && 
                    resp.data.batteryRespMessage.plugStatus == 1){
                  _this.chargeStatusText = '充电桩未插枪-充电中（接触器吸合）' + isCharging
           }else if( resp.data.batteryRespMessage.workStatus === 0 && 
                  resp.data.batteryRespMessage.chargeStatus === 2 && 
                  resp.data.batteryRespMessage.plugStatus === 2){
                  _this.chargeStatusText = '充电桩插枪-充电中（接触器吸合）' + isCharging
           }else if( resp.data.batteryRespMessage.workStatus == 0 && 
                 resp.data.batteryRespMessage.chargeStatus == 3 && 
                 resp.data.batteryRespMessage.plugStatus == 2){
                  _this.chargeStatusText = '充电桩插枪-等待启动(接触器未吸合)' + isCharging
            }else if( resp.data.batteryRespMessage.workStatus == 0 && 
                resp.data.batteryRespMessage.chargeStatus == 3 && 
                resp.data.batteryRespMessage.plugStatus == 1){
                 _this.chargeStatusText = '充电桩未插枪-等待启动(接触器未吸合)' + isCharging
            }else if( resp.data.batteryRespMessage.workStatus == 0 && 
                resp.data.batteryRespMessage.chargeStatus == 4 && 
                resp.data.batteryRespMessage.plugStatus == 1){
                _this.chargeStatusText = '充电桩未插枪-充电中(直流信号模式)' + isCharging
            }else if( resp.data.batteryRespMessage.workStatus == 0 && 
                resp.data.batteryRespMessage.chargeStatus == 4 && 
                resp.data.batteryRespMessage.plugStatus == 2){
                _this.chargeStatusText = '充电桩插枪-充电中(直流信号模式]' + isCharging
            }else if( resp.data.batteryRespMessage.workStatus == 0 && 
            resp.data.batteryRespMessage.chargeStatus == 5 && 
            resp.data.batteryRespMessage.plugStatus == 2){
                _this.chargeStatusText = '充电桩插枪-等待启动中(直流信号模式]' + isCharging

            }else if( resp.data.batteryRespMessage.workStatus == 0 && 
            resp.data.batteryRespMessage.chargeStatus == 5 && 
            resp.data.batteryRespMessage.plugStatus == 1){
                _this.chargeStatusText = '充电桩未插枪-等待启动中(直流信号模式]' + isCharging
            }  
            else if(resp.data.batteryRespMessage.workStatus == 4 || resp.data.batteryRespMessage.workStatus == 1){
                _this.chargeStatusText = '此充电桩急停按下' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 5){
                _this.chargeStatusText = '欠压结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 6){
                _this.chargeStatusText = '过流结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 7){
                _this.chargeStatusText = '485召表不通结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 8){
                _this.chargeStatusText = '充电枪断开结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 9){
                _this.chargeStatusText = '过压结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 10){
                _this.chargeStatusText = '硬件故障结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 11){
                _this.chargeStatusText = '漏电流故障结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 12){
                _this.chargeStatusText = '余额不足结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 13){
                _this.chargeStatusText = '断电结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 14){
                _this.chargeStatusText = 'CP非法电压结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 15){
                _this.chargeStatusText = '交流接触器故障结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 16){
                _this.chargeStatusText = '充电桩过温结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 17){
                _this.chargeStatusText = '充电枪过温结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 18){
                _this.chargeStatusText = '从板通讯故障结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 19){
                _this.chargeStatusText = '电子锁故障结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 20){
                _this.chargeStatusText = '防雷故障结束充电' + isCharging
            }else if(resp.data.batteryRespMessage.workStatus == 21){
                _this.chargeStatusText = '电价获取故障结束充电' + isCharging
            }else{
                _this.chargeStatusText = '其他故障' + isCharging
           }}
           _this.loading = false;
          })
         .catch(resp => {
          if(resp.errmsg.indexOf("not.online") != -1){
            alert('此充电桩已离线!')
          }else if(resp.errmsg.indexOf("not.owner") != -1){
            alert('您没有操作权限!')
          }else if(resp.errmsg.indexOf("not.exist") != -1){
            alert('此充电桩不存在!')
          }else{}
          _this.loading = false;
        })
        
      }else{
        alert("请输入mac")
      }
      },

      SearchState4(){
         var _this = this;
         if(_this.lockMac != null && _this.lockMac != undefined && _this.lockMac != ''){
        _this.flagShow2 = false;_this.flagShow3 = false;_this.flagShow1 = false;_this.flagShow5 = false;_this.flagShow6 = false;_this.flagShow7 = false;_this.flagShow8 = false;
        _this.flagShow9 = false; 
        _this.flagShow4 = true;
            _this.loading = true;
            getPicApi(_this.lockMac,_this.roleCode).then(resp => {  
            if(resp.errmsg == 'ok'){ 
                _this.src = resp.data

            _this.loading = false;
            }
        })
        .catch(resp => {
          if(resp.errmsg.indexOf("not.online") != -1){
            alert('此泊控器已离线!')
          }else if(resp.errmsg.indexOf("not.owner") != -1){
            alert('您没有操作权限!')
          }else if(resp.errmsg.indexOf("not.exist") != -1){
            alert('此泊控器不存在!')
          }else{}
          _this.loading = false;
        })
      }else{
        alert("请输入mac")
      }
      },

      SearchState5(){
         var _this = this;
         if(_this.lockMac != null && _this.lockMac != undefined && _this.lockMac != ''){
        _this.flagShow2 = false;_this.flagShow3 = false;_this.flagShow4 = false;_this.flagShow1 = false;_this.flagShow6 = false;_this.flagShow7 = false;_this.flagShow8 = false;
        _this.flagShow9 = false; 
        _this.flagShow5 = true;
            _this.loading = true;
        lockStatusApi(_this.lockMac,_this.roleCode).then(resp => {  
        if(resp.errmsg == 'ok'){ 
          if (resp.data.data == "1") {
            _this.lockStatusText='解锁状态'
        } else if (resp.data.data == "2") {
            _this.lockStatusText='锁定状态'
        } else if (resp.data.data == "3") {
            _this.lockStatusText='中间状态'
        } else if (resp.data.data == "6") {
            _this.lockStatusText='下降遇阻力保持不动'
        } else if (resp.data.data == "7") {
            _this.lockStatusText='电池电量低'
        } else if (resp.data.data == "8") {
            _this.lockStatusText='雷达异常'
        } else if (resp.data.data == "9") {
            _this.lockStatusText='微动异常'
        } else if (resp.data.data == "a") {
            _this.lockStatusText='电机异常'
        } else if (resp.data.data == "b") {
            _this.lockStatusText='上升遇阻力下降至底部'
        } else {
            _this.lockStatusText='未知状态'
        }
            _this.loading = false;
            }
        })
        .catch(resp => {
          if(resp.errmsg.indexOf("not.online") != -1){
            alert('此泊控器已离线!')
          }else if(resp.errmsg.indexOf("not.owner") != -1){
            alert('您没有操作权限!')
          }else if(resp.errmsg.indexOf("not.exist") != -1){
            alert('此泊控器不存在!')
          }else{}
          _this.loading = false;
        })
      }else{
        alert("请输入mac")
      }
      },
  
      SearchState6(){
         var _this = this;
         if(_this.lockMac != null && _this.lockMac != undefined && _this.lockMac != ''){
        _this.flagShow2 = false;_this.flagShow3 = false;_this.flagShow4 = false;_this.flagShow5 = false;_this.flagShow1 = false;_this.flagShow7 = false;_this.flagShow8 = false;
        _this.flagShow9 = false; 
        _this.flagShow6 = true;
            _this.loading = true;
            getLiveImageApi(_this.lockMac,_this.roleCode,_this.onLight).then(resp => {  
            if(resp.errmsg == 'ok'){ 
                
                _this.getLiveImageText = resp.data.liveImagePath
            _this.loading = false;
            }
        })
        .catch(resp => {
          
         alert("图像采集失败！")
         _this.loading = false;
        })
      }else{
        alert("请输入mac")
      }
      },

      
    Channelcheck3() {
      var _this = this;

   
      var faultDesc = _this.feeForm.faultDesc;

      if(_this.feeForm.faultDesc == "0"){

         faultDesc = "设备离线";

      }else if(_this.feeForm.faultDesc == "1"){
        
        faultDesc = "设备断电";

      }else if(_this.feeForm.faultDesc == "2"){
  
        faultDesc = "起落异常";

      }else if(_this.feeForm.faultDesc == "3"){
  
          faultDesc = "充电异常";

        }else if(_this.feeForm.faultDesc == "4"){
  
        faultDesc = "部件损坏";

      }
      // else if(_this.feeForm.faultDesc == "5"){
      //   faultDesc = "其他";
      // }

      var procMethod = _this.feeForm.procMethod;

      if(_this.feeForm.procMethod == "0"){
        
         procMethod = "现场排查";

      }else if(_this.feeForm.procMethod == "1"){

        procMethod = "断电重启";

      }else if(_this.feeForm.procMethod == "2"){

        procMethod = "插拔通讯模块";
        
      }else if(_this.feeForm.procMethod == "3"){

        procMethod = "更换电路板";

        }else if(_this.feeForm.procMethod == "4"){

        procMethod = "更换枪线";

        }else if(_this.feeForm.procMethod == "5"){

        procMethod = "钣金修复";

        }else if(_this.feeForm.procMethod == "6"){

          procMethod = "更换雷达";

          }else if(_this.feeForm.procMethod == "7"){

          procMethod = "更换部件";

          }else if(_this.feeForm.procMethod == "8"){

            procMethod = "更换电路控制板";

            }else if(_this.feeForm.procMethod == "9"){

                 procMethod = "更换开关电源";

            }else if(_this.feeForm.procMethod == "10"){

              procMethod = "更换电机控制器";

            }else if(_this.feeForm.procMethod == "11"){

              procMethod = "更换空开";

            }else if(_this.feeForm.procMethod == "12"){

              procMethod = "更换急停";

              }else if(_this.feeForm.procMethod == "13"){

                procMethod = "更换电表";

                }else if(_this.feeForm.procMethod == "14"){

               procMethod = "自动恢复";

              }else if(_this.feeForm.procMethod == "15"){

                procMethod = "人工处理";

                }
                // else  if(_this.feeForm.procMethod == "16"){

                // procMethod = "其他";

                // }
                
      let pos = _this.feeForm.lockName.indexOf("------");

  
      console.log(faultDesc);
      
      if(faultDesc != "设备离线" &&  faultDesc != "设备断电" && faultDesc != "起落异常" && faultDesc != "充电异常" && faultDesc != "部件损坏"){

            _this.$notify({
            title: "错误提示",
            message: "故障信息描述错误",
            type: "success"
            });

            return;

            }

      const data = {
        faultNo:_this.feeForm.faultNo,
        lockMac:_this.feeForm.lockMac,
        lockName:_this.feeForm.lockName.substring(0,pos),
        faultDesc:faultDesc.replace(/\r+|\n+| +/g, ''),
        procMethod:procMethod.replace(/\r+|\n+| +/g, ''),
        faultSource:_this.feeForm.faultSource,
        isReport:_this.feeForm.isReport == false ? 0 : 1,
        opPerson:_this.feeForm.opPerson.replace(/\r+|\n+| +/g, ''),
      };
      // opPerson:_this.feeForm.opPerson == '' ? '' : _this.feeForm.opPerson.replace(/\r+|\n+| +/g, ''),
    //  if(_this.feeForm.faultNo ==null || _this.feeForm.faultNo ==''){alert("mac不能为空！");return false;}
    //  if(_this.feeForm.lockName ==null || _this.feeForm.lockName ==''){alert("站点名称不能为空！");return false;}
    //  if(_this.feeForm.faultDesc ==null || _this.feeForm.faultDesc ==''){alert("问题描述不能为空！");return false;}
    //  if(_this.feeForm.procMethod ==null || _this.feeForm.procMethod ==''){alert("解决方案不能为空！");return false;}
    //  if(_this.feeForm.faultSource !='0'){
    //  if(_this.feeForm.faultSource ==null || _this.feeForm.faultSource ==''){alert("问题来源不能为空！");return false;}}
    //  if(_this.feeForm.opPerson ==null || _this.feeForm.opPerson ==''){alert("推送人员不能为空！");return false;}
  
    _this.$refs.feeForm.validate((valid) => {
        if (valid) {
  
     lcfaultprocApi(data).then(function (resp) {
          if (resp.errmsg === "ok") {
            _this.$notify({
              title: "成功",
              message: "修改成功",
              type: "success",
            });
            _this.addDialog3 = false;

          }
        })
        .catch(function (resp) {
          _this.$notify({
            title: "失败",
            message: "修改失败，请稍后重试。",
            type: "error",
          });
        });
        }
      })
      },

      SearchState7(){
         var _this = this;
         if(_this.lockMac != null && _this.lockMac != undefined && _this.lockMac != ''){
        _this.flagShow2 = false;_this.flagShow3 = false;_this.flagShow4 = false;_this.flagShow5 = false;_this.flagShow6 = false;_this.flagShow7 = false;_this.flagShow8 = false;
        _this.flagShow9 = false; 
        _this.flagShow7 = true;
            _this.loading = true;
        radarApi(_this.lockMac,_this.roleCode).then(resp => {  
        if(resp.errmsg == 'ok'){ 
          if (resp.data.data == "1") {
            _this.radarText='有车'
          }else if(resp.data.data == "2"){
            _this.radarText='无车'
          }else if(resp.data.data == "3"){
            _this.radarText='雷达关闭'
          }else if(resp.data.data == "4"){
            _this.radarText='雷达异常' + resp.data.data
          }
            _this.loading = false;
            }
        })
        .catch(resp => {
          if(resp.errmsg.indexOf("not.online") != -1){
            alert('此泊控器已离线!')
          }else if(resp.errmsg.indexOf("not.owner") != -1){
            alert('您没有操作权限!')
          }else if(resp.errmsg.indexOf("not.exist") != -1){
            alert('此泊控器不存在!')
          }else{}
          _this.loading = false;
        })
      }else{
        alert("请输入mac")
      }
      },

      SearchState8(){
         var _this = this;
         if(_this.lockMac != null && _this.lockMac != undefined && _this.lockMac != ''){
        _this.flagShow2 = false;_this.flagShow3 = false;_this.flagShow4 = false;_this.flagShow5 = false;_this.flagShow6 = false;_this.flagShow7 = false;_this.flagShow1 = false;
        _this.flagShow9 = false;      
        _this.flagShow8 = true;
                _this.loading = true;
      queryRadarDistApi(_this.lockMac,_this.roleCode).then(resp => {  
        if(resp.errmsg == 'ok'){ 
            var dist = resp.data.data.split(",");
            _this.queryRadarDistText =  dist[0]+"," +  dist[1] + ","+ dist[2]+ "," +dist[3]+  "(mm)"
            _this.queryRadarDistText2 = dist[4]
            _this.loading = false;
            }
        })
        .catch(resp => {
          if(resp.errmsg.indexOf("not.online") != -1){
            alert('此充电桩已离线!')
          }else if(resp.errmsg.indexOf("not.owner") != -1){
            alert('您没有操作权限!')
          }else if(resp.errmsg.indexOf("not.exist") != -1){
            alert('此充电桩不存在!')
          }else{}
          _this.loading = false;
        })
      }else{
        alert("请输入mac")
      }
      },


      SearchState9(){
         var _this = this;
         if(_this.lockMac != null && _this.lockMac != undefined && _this.lockMac != ''){
        _this.flagShow2 = false;_this.flagShow3 = false;_this.flagShow4 = false;_this.flagShow5 = false;_this.flagShow6 = false;_this.flagShow7 = false;_this.flagShow1 = false;
        _this.flagShow8 = false;
        _this.flagShow9 = true;


        this.$confirm('需要视频监控配合,确定复位泊控器吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
         

          _this.loading = true;
        softResetApi(_this.lockMac,_this.roleCode).then(resp => {  
        if(resp.errmsg == 'ok'){ 

          if (resp.data.data == 1) {
            _this.clear = '故障清除成功';
          }else{
            _this.clear = '故障清除异常：' + resp.data.data;
          }
            _this.loading = false;
            }
        })
        .catch(resp => {
          if(resp.errmsg.indexOf("not.online") != -1){
            alert('此充电桩已离线!')
          }else if(resp.errmsg.indexOf("not.owner") != -1){
            alert('您没有操作权限!')
          }else if(resp.errmsg.indexOf("not.exist") != -1){
            alert('此充电桩不存在!')
          }else{}
          _this.loading = false;
        })


        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });          
        });
    

        
      }else{
        alert("请输入mac")
      }
      },


      
      checkval(value){
            if(value == true){
                this.onLight = 1
            }else{
                this.onLight = 0
            }
      },

      checkValue(e){
          var _this = this

          if(e == true){
            _this.feeForm.isReport = true
            _this.feeForm.procRate = 2
          }else if(e == false){
            _this.feeForm.isReport = false
            _this.feeForm.procRate = 1
          }
        },

      queryBtn () {
        let _this = this;

        if(_this.queryParams.userId.substring(0,3) == '555'){
           _this.showPark = false
           _this.Other = true
        }else{
          _this.showPark = true
           _this.Other = false
        }
  
        if(_this.queryParams.userId != null && _this.queryParams.userId != undefined && _this.queryParams.userId != ''){
         loadMacApi({mac:_this.queryParams.userId}).then(resp => {     
            if(resp.errmsg == 'ok'){
            if(resp.data.lockType == 0){
              _this.lockType = '扫码充电'
            }else if(resp.data.lockType == 3){
              _this.lockType = '纯泊控器'

            }else{
              _this.lockType = '纯充电桩'
              _this.showPark = false
              _this.showOther = true

            }    
                _this.parkfieldName =  resp.data.lockAddress + '------' + (_this.lockType)
                _this.lockMac = resp.data.lockMac
                _this.managerName = resp.data.managerName
            }
        })
        .catch(function () {
            alert("mac无效,请重新输入!")
        });
      }else{
        alert("请输入mac")
      }
      },
      queryBtn2(){
        // this.loadPerson()
         let _this = this;
         if(_this.parkfieldName != null && _this.parkfieldName != undefined && _this.parkfieldName != ''){
        _this.feeForm.faultNo = '';
        _this.feeForm.lockMac = '';
        _this.feeForm.lockName = '';
        // _this.feeForm.faultDesc = '';
        _this.feeForm.procMethod = '';
        _this.feeForm.faultSource = '';
        _this.feeForm.isReport = false;
        _this.feeForm.opPerson = '';
        _this.checked = false; 
        _this.feeForm.isReport = false
        _this.feeForm.procRate = 1
        _this.feeForm.opPerson = ''

          const now = new Date()
        let month = now.getMonth() + 1
        let day = now.getDate()
        let hour = now.getHours()
        let minutes = now.getMinutes()
        let seconds = now.getSeconds()
        let randomNumber = now.getFullYear().toString() + month.toString() + day + hour + minutes + seconds
        var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        var randomString = "";
        for (var i = 0; i < 8; i++) {
          var randomIndex = Math.floor(Math.random() * chars.length);
          randomString += chars.charAt(randomIndex);
        }
        

        _this.feeForm.lockMac = _this.queryParams.userId;
        _this.feeForm.lockName = _this.parkfieldName;


        if(_this.$route.query.lockMac == '' || _this.$route.query.lockMac == null || _this.$route.query.lockMac == undefined  ){
          _this.feeForm.faultDesc = '';
  
        }else{
        
        }

        if(_this.$route.query.faultNo == '' || _this.$route.query.faultNo == null || _this.$route.query.faultNo == undefined 
        || _this.queryParams.userId != this.$route.query.lockMac){

          _this.feeForm.faultNo = randomNumber + randomString

    

        }else{
          _this.feeForm.faultNo = _this.$route.query.faultNo
        }
       



        _this.addDialog3 = true;


        }else{
        alert("泊位名称不能为空！")
      }
      },
      cancle3(){
      let _this = this;
      _this.addDialog3 = false;
     
    },
    },
    computed: {
      userState () {
        return getNickName() === getTestUserName();
      }
    },
    mounted: function () {

        this.roleCode = getRoleCode()
        this.loadParkfields()
        this.queryParams.userId = this.$route.query.lockMac
        this.faultNo = this.$route.query.faultNo
        this.parkfieldName = this.$route.query.lockName
        this.feeForm.faultDesc = this.$route.query.feedbackDetails
        
  this.queryBtn();
        console.log("99999999999",faultNo) 
    }
  };
  </script>
  
  <style scoped>
  .page-tool {
    background:#dfeaf9;
  }
  
  .page-tool div {
    text-align: right;
  }
  .flag{
    color:#ff770f;
    font-weight:600;
    font-size:24px;
    margin-left: 10px;
    line-height: 32px;
  }
  .lock-btn {
    margin-bottom: 5px;
    margin-top: -10px;
  }
  .operateBtn {
    font-size: 18px;
    width: 32px;
    height: 32px;
    padding: 0;
  }
  </style>